#    pythonequations is a collection of equations expressed as Python classes
#    Copyright (C) 2008 James R. Phillips
#    2548 Vera Cruz Drive
#    Birmingham, AL 35235 USA
#    email: zunzun@zunzun.com
#
#    License: BSD-style (see LICENSE.txt in main source directory)
#    Version info: $Id: Sigmoidal.py 274 2010-09-29 13:16:14Z zunzun.com $

import pythonequations, pythonequations.EquationBaseClasses, pythonequations.ExtraCodeForEquationBaseClasses
import numpy
numpy.seterr(all = 'raise') # numpy raises warnings, convert to exceptions to trap them


class GeneralisedLogistic2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Generalised Logistic"
    _HTML = "y = A + C / (1 + T * exp(-B * (x - M)))<sup>1/T</sup>"

    webCitationLink = 'http://www.knowledgerush.com/kr/encyclopedia/Generalised_logistic_curve/'
    coefficientDesignatorTuple = ('A', 'C', 'M', 'B', 'T')
    function_cpp_code = 'temp = coeff[0] + coeff[1] / pow(1.0 + coeff[4] * exp(-1.0 * coeff[3] * (_id[_cwo[0]+i] - coeff[2])), 1.0 / coeff[4]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = A + C / pow(1.0 + T * exp(-1.0 * B * (x_in - M)), 1.0 / T);\n"
        return s



class FourParameterLogistic2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Four-Parameter Logistic"
    _HTML = "y = d + (a-d) / (1.0 + (x/c)<sup>b</sup>)"

    coefficientDesignatorTuple = ('a', 'b', 'c', 'd')
    function_cpp_code = 'temp = coeff[3] + (coeff[0] - coeff[3]) / (1.0 + pow(_id[_cwo[0]+i]/coeff[2], coeff[1]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = d + (a - d) / (1.0 + pow(x_in / c, b));\n"
        return s



class FiveParameterLogistic2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Five-Parameter Logistic"
    _HTML = "y = d + (a-d) / (1.0 + (x/c)<sup>b</sup>)<sup>e</sup>"

    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'e')
    function_cpp_code = 'temp = coeff[3] + (coeff[0] - coeff[3]) / pow(1.0 + pow(_id[_cwo[0]+i]/coeff[2], coeff[1]), coeff[4]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = d + (a - d) / pow(1.0 + pow(x_in / c, b), e);\n"
        return s



class Janoschek2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Janoschek Growth"
    _HTML = "w = a - (1.0 - exp(-b * t<sup>c</sup>))"

    webCitationLink = 'http://www.uni-leipzig.de/~vetana/growthe.htm'
    coefficientDesignatorTuple = ('a', 'b', 'c')
    function_cpp_code = 'temp = coeff[0] - (1.0 - exp(-1.0 * coeff[1] * pow(_id[_cwo[0]+i], coeff[2])));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a - (1.0 - exp(-1.0 * b * pow(x_in, c)));\n"
        return s



class Janoschek_Modified2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Janoschek Growth Modified"
    _HTML = "w = a - (a - w0) * (1.0 - exp(-b * t<sup>c</sup>))"

    webCitationLink = 'http://www.uni-leipzig.de/~vetana/growthe.htm'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'w0')
    function_cpp_code = 'temp = coeff[0] - (coeff[0] - coeff[3]) * (1.0 - exp(-1.0 * coeff[1] * pow(_id[_cwo[0]+i], coeff[2])));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a - (1.0 - (a - w0) * exp(-1.0 * b * pow(x_in, c)));\n"
        return s



class MorganMercerFlodin2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Morgan-Mercer-Flodin (MMF)"
    _HTML = "y = (a * b + c * x<sup>d</sup>) / (b + x<sup>d</sup>)"
    coefficientDesignatorTuple = ("a", "b", "c", 'd')
    function_cpp_code = 'temp = (coeff[0] * coeff[1] + coeff[2] * pow(_id[_cwo[0]+i], coeff[3])) / (coeff[1] + pow(_id[_cwo[0]+i], coeff[3]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = (a * b + c * pow(x_in, d) / (b + pow(x_in, d));\n"
        return s



class Richards2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Richards"
    _HTML = "y = 1.0 / (a + b * e<sup>(c*x)</sup>)<sup>d</sup>"
    coefficientDesignatorTuple = ("a", "b", "c", 'd')
    function_cpp_code = 'temp = 1.0 / pow(coeff[0] + coeff[1] * exp(coeff[2] * _id[_cwo[0]+i]), coeff[3]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = 1.0 / pow(a + b * exp(c*x_in), d);\n"
        return s



class PetersBaskin_Y_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: y (1)"
    _HTML = "y = ln(c + exp(b*d*x)) / d"

    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b', 'c', 'd')
    function_cpp_code = 'temp = log(coeff[1] + exp(coeff[0] * coeff[2] * _id[_cwo[0]+i])) / coeff[2];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = log(c + exp(b * d * x_in)) / d;\n"
        return s



class PetersBaskin_YI_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yI (2)"
    _HTML = "yI = ln(exp(b2*c1*d1) + exp(b2*d1*x)) / d1"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1')
    function_cpp_code = 'temp = log(exp(coeff[0] * coeff[1] * coeff[2]) + exp(coeff[0] * coeff[2] * _id[_cwo[0]+i])) / coeff[2];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = log(exp(b2 * c1 * d1) + exp(b2 * d1 * x_in)) / d1;\n"
        return s



class PetersBaskin_YII_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yII (3)"
    _HTML = "K = ln( exp(b2*c1*d1) + exp(b2*d1*x) )<br>"
    _HTML += "yII = b1*x + K/d1"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1', 'b1')
    function_cpp_code = 'temp = coeff[3] * _id[_cwo[0]+i] + log(exp(coeff[0] * coeff[1] * coeff[2]) + exp(coeff[0] * coeff[2] * _id[_cwo[0]+i])) / coeff[2];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = b1 * x_in + log(exp(b2 * c1 * d1) + exp(b2 * d1 * x_in)) / d1;\n"
        return s



class PetersBaskin_YIII_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yIII (6)"
    _HTML = "K = ln( exp(b2*c1*d1) + exp(b2*d1*x) )<br>"
    _HTML += "yII = b1*x + K/d1<br>"
    _HTML += "L = ln( exp(b2*c1*d1) + exp(b2*c2*d1) )<br>"
    _HTML += "yIII = yII - ln( exp(d2*(b1*c1 + L/d1)) + exp(d2*yII) ) / d2"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1', 'b1', 'c2', 'd2')
    
    function_cpp_code = 'temp_x_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[2]*_id[_cwo[0]+i]) );' # K used in yII on the next line
    function_cpp_code += 'temp_y_sq = coeff[3]*_id[_cwo[0]+i] + temp_x_sq/coeff[2];' # yII
    function_cpp_code += 'temp_x_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[4]*coeff[2]) );' # L
    function_cpp_code += 'temp = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp_x_sq/coeff[2])) + exp(coeff[5]*temp_y_sq) ) / coeff[5];'
	
	
    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = ""
        s += '\tdouble K = log( exp(b2*c1*d1) + exp(b2*d1*x_in) );\n'
        s += '\tdouble yII = b1*x_in + K/d1;\n'
        s += '\tdouble L = log( exp(b2*c1*d1) + exp(b2*c2*d1) );\n'
        s += '\ttemp = yII - log( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2;\n'
        return s



class PetersBaskin_YIV_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yIV (9)"
    _HTML = "K = ln( exp(b2*c1*d1) + exp(b2*d1*x) )<br>"
    _HTML += "yII = b1*x + K/d1<br>"
    _HTML += "L = ln( exp(b2*c1*d1) + exp(b2*c2*d1) )<br>"
    _HTML += "yIII = yII - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2<br>"
    _HTML += "yII,0 = ln(exp(b2*c1*d1) + 1.0 ) / d1<br>"
    _HTML += "yIII,0 = yII,0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII,0) ) / d2<br>"
    _HTML += "yIV = yIII - yIII,0"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1', 'b1', 'c2', 'd2')
    
    function_cpp_code = 'temp_x_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[2]*_id[_cwo[0]+i]) );' # K used in yII on the next line
    function_cpp_code += 'temp_y_sq = coeff[3]*_id[_cwo[0]+i] + temp_x_sq/coeff[2];' # yII
    function_cpp_code += 'temp = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[4]*coeff[2]) );' # L
    function_cpp_code += 'temp_x_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq) ) / coeff[5];' # YIII
    function_cpp_code += 'temp_y_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + 1.0 ) / coeff[2];' # YII,0
    function_cpp_code += 'temp_y_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq)) / coeff[5];' # YIII,0
    function_cpp_code += 'temp = temp_x_sq - temp_y_sq;'
	
	
    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = ""
        s += '\tdouble K = log( exp(b2*c1*d1) + exp(b2*d1*x_in) );\n'
        s += '\tdouble yII = b1*x_in + K/d1;\n'
        s += '\tdouble L = log( exp(b2*c1*d1) + exp(b2*c2*d1) );\n'
        s += '\tdouble yIII = yII - log( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2;\n'
        s += '\tdouble yII_0 = log( exp(b2*c1*d1) + 1.0) / d1;\n'
        s += '\tdouble yIII_0 = yII_0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII_0) ) / d2;\n'
        s += '\ttemp = yIII - yIII_0;\n'
        return s



class PetersBaskin_YV_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yV (10)"
    _HTML = "K = ln( exp(b2*c1*d1) + exp(b2*d1*x) )<br>"
    _HTML += "yII = b1*x + K/d1<br>"
    _HTML += "L = ln( exp(b2*c1*d1) + exp(b2*c2*d1) )<br>"
    _HTML += "yIII = yII - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2<br>"
    _HTML += "yII,0 = ln(exp(b2*c1*d1) + 1.0 ) / d1<br>"
    _HTML += "yIII,0 = yII,0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII,0) ) / d2<br>"
    _HTML += "yIV = yIII - yIII,0 + q"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1', 'b1', 'c2', 'd2', 'q')
    
    function_cpp_code = 'temp_x_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[2]*_id[_cwo[0]+i]) );' # K used in yII on the next line
    function_cpp_code += 'temp_y_sq = coeff[3]*_id[_cwo[0]+i] + temp_x_sq/coeff[2];' # yII
    function_cpp_code += 'temp = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[4]*coeff[2]) );' # L
    function_cpp_code += 'temp_x_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq) ) / coeff[5];' # YIII
    function_cpp_code += 'temp_y_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + 1.0 ) / coeff[2];' # YII,0
    function_cpp_code += 'temp_y_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq)) / coeff[5];' # YIII,0
    function_cpp_code += 'temp = temp_x_sq - temp_y_sq + coeff[6];'
	
	
    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = ""
        s += '\tdouble K = log( exp(b2*c1*d1) + exp(b2*d1*x_in) );\n'
        s += '\tdouble yII = b1*x_in + K/d1;\n'
        s += '\tdouble L = log( exp(b2*c1*d1) + exp(b2*c2*d1) );\n'
        s += '\tdouble yIII = yII - log( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2;\n'
        s += '\tdouble yII_0 = log( exp(b2*c1*d1) + 1.0) / d1;\n'
        s += '\tdouble yIII_0 = yII_0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII_0) ) / d2;\n'
        s += '\ttemp = yIII - yIII_0 + q;\n'
        return s



class PetersBaskin_YV_Scaled_2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    
    _name = "Peters-Baskin Step-Stool: yV (10) Scaled"
    _HTML = "K = ln( exp(b2*c1*d1) + exp(b2*d1*x) )<br>"
    _HTML += "yII = b1*x + K/d1<br>"
    _HTML += "L = ln( exp(b2*c1*d1) + exp(b2*c2*d1) )<br>"
    _HTML += "yIII = yII - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2<br>"
    _HTML += "yII,0 = ln(exp(b2*c1*d1) + 1.0 ) / d1<br>"
    _HTML += "yIII,0 = yII,0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII,0) ) / d2<br>"
    _HTML += "yIV = scale * (yIII - yIII,0 )+ q"
    
    webCitationLink = 'http://www.plantmethods.com/content/2/1/11'
    coefficientDesignatorTuple = ('b2', 'c1', 'd1', 'b1', 'c2', 'd2', 'q', 'scale')
    
    function_cpp_code = 'temp_x_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[2]*_id[_cwo[0]+i]) );' # K used in yII on the next line
    function_cpp_code += 'temp_y_sq = coeff[3]*_id[_cwo[0]+i] + temp_x_sq/coeff[2];' # yII
    function_cpp_code += 'temp = log( exp(coeff[0]*coeff[1]*coeff[2]) + exp(coeff[0]*coeff[4]*coeff[2]) );' # L
    function_cpp_code += 'temp_x_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq) ) / coeff[5];' # YIII
    function_cpp_code += 'temp_y_sq = log( exp(coeff[0]*coeff[1]*coeff[2]) + 1.0 ) / coeff[2];' # YII,0
    function_cpp_code += 'temp_y_sq = temp_y_sq - log( exp(coeff[5]*(coeff[3]*coeff[4] + temp/coeff[2])) + exp(coeff[5]*temp_y_sq)) / coeff[5];' # YIII,0
    function_cpp_code += 'temp = coeff[7] * (temp_x_sq - temp_y_sq) + coeff[6];'
	
	
    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = ""
        s += '\tdouble K = log( exp(b2*c1*d1) + exp(b2*d1*x_in) );\n'
        s += '\tdouble yII = b1*x_in + K/d1;\n'
        s += '\tdouble L = log( exp(b2*c1*d1) + exp(b2*c2*d1) );\n'
        s += '\tdouble yIII = yII - log( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII) ) / d2;\n'
        s += '\tdouble yII_0 = log( exp(b2*c1*d1) + 1.0) / d1;\n'
        s += '\tdouble yIII_0 = yII_0 - ln( exp(d2*(b1*c2 + L/d1)) + exp(d2*yII_0) ) / d2;\n'
        s += '\ttemp = scale * (yIII - yIII_0) + q;\n'
        return s



class DonLevinSigmoid2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Don Levin Sigmoid"
    _HTML = "y = a1 / (1.0 + exp(-(x-b1)/c1)) + a2 / (1.0 + exp(-(x-b2)/c2)) + a3 / (1.0 + exp(-(x-b3)/c3))"
    coefficientDesignatorTuple = ("a1", "b1", "c1", "a2", "b2", "c2", "a3", "b3", "c3")
    function_cpp_code = 'temp = coeff[0] / (1.0 + exp(-1.0 * (_id[_cwo[0]+i] - coeff[1]) / coeff[2])) + coeff[3] / (1.0 + exp(-1.0 * (_id[_cwo[0]+i] - coeff[4]) / coeff[5])) + coeff[6] / (1.0 + exp(-1.0 * (_id[_cwo[0]+i] - coeff[7]) / coeff[8]));'

    guessDivisor = 100.0


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a1 / (1.0 + exp(-1.0 * (x_in - b1) / c1)) + a2 / (1.0 + exp(-1.0 * (x_in - b2) / c2)) + a3 / (1.0 + exp(-1.0 * (x_in - b3) / c3));\n"
        return s



class BET_Sigmoidal_A2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "BET Sigmoidal A"
    _HTML = "y = x / (a + bx - (a+b)x<sup>2</sup>)"
    coefficientDesignatorTuple = ("a", "b")
    function_cpp_code = 'temp = _id[_cwo[0]+i] / (coeff[0] + (coeff[1] * _id[_cwo[0]+i]) - ((coeff[0] + coeff[1]) * _id[_cwo[1]+i]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_PowX(NameOrValueFlag=1, args=[2.0]), [2.0]])

    def SpecificCodeCPP(self):
        s = "\ttemp = x_in / (a + (b * x_in) - (( a+ b) * x_in * x_in));\n"
        return s



class BET_Sigmoidal_B2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "BET Sigmoidal B"
    _HTML = "y = abx / (1.0 + (b-2.0)x - (b-1.0)x<sup>2</sup>)"
    coefficientDesignatorTuple = ("a", "b")
    function_cpp_code = 'temp = coeff[0] * coeff[1] * _id[_cwo[0]+i] / (1.0 + ((coeff[1] - 2.0) * _id[_cwo[0]+i]) - ((coeff[1] - 1.0) * _id[_cwo[1]+i]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_PowX(NameOrValueFlag=1, args=[2.0]), [2.0]])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * b * x_in / (1.0 + ((b - 2.0) * x_in) - ((b - 1.0) * x_in * x_in));\n"
        return s



class BoltzmannSigmoid2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Boltzmann Sigmoid"
    _HTML = "y = (a - b) / (1.0 + exp((x-c)/d)) + b"
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd')
    function_cpp_code = 'temp = (coeff[0] - coeff[1]) / (1.0 + exp((_id[_cwo[0]+i] - coeff[2]) / coeff[3])) + coeff[1];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = (a - b) / (1.0 + exp((x_in - c) / d)) + b;\n"
        return s



class SigmoidA2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Sigmoid A"
    _HTML = "y = 1.0 / (1.0 + exp(-a(x-b)))"
    coefficientDesignatorTuple = ("a", "b")
    function_cpp_code = 'temp = 1.0 / (1.0 + exp(-1.0 * coeff[0] * (_id[_cwo[0]+i] - coeff[1])));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = 1.0 / (1.0 + exp(-1.0 * a * (x_in - b)));\n"
        return s



class SigmoidA_Modified2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Sigmoid A Modified"
    _HTML = "y = 1.0 / (1.0 + exp(-a(x-b)))<sup>c</sup>"
    coefficientDesignatorTuple = ("a", "b", 'c')
    function_cpp_code = 'temp = 1.0 / pow(1.0 + exp(-1.0 * coeff[0] * (_id[_cwo[0]+i] - coeff[1])), coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = 1.0 / pow(1.0 + exp(-1.0 * a * (x_in - b)), c);\n"
        return s



class SigmoidB2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Sigmoid B"
    _HTML = "y = a / (1.0 + exp(-(x-b)/c))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] / (1.0 + exp(-1.0 * (_id[_cwo[1]+i] - coeff[1]) / coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a / (1.0 + exp(-1.0 * (x_in - b) / c));\n"
        return s



class SigmoidB_Modified2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Sigmoid B Modified"
    _HTML = "y = a / (1.0 + exp(-(x-b)/c))<sup>d</sup>"
    coefficientDesignatorTuple = ("a", "b", "c", 'd')
    function_cpp_code = 'temp = coeff[0] / pow(1.0 + exp(-1.0 * (_id[_cwo[0]+i] - coeff[1]) / coeff[2]), coeff[3]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a / pow(1.0 + exp(-1.0 * (x_in - b) / c), d);\n"
        return s



class GompertzA2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Gompertz A"
    _HTML = "y = a * exp(-exp(b - cx))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * exp(-1.0 * exp(coeff[1] - _id[_cwo[0]+i] * coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * exp(-1.0 * exp(b - c*x_in));\n"
        return s



class GompertzB2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Gompertz B"
    _HTML = "y = a * exp(-exp((x-b)/c))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * exp(-1.0 * exp((_id[_cwo[0]+i] - coeff[1]) / coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * exp(-1.0 * exp((x_in - b)/c));\n"
        return s



class GompertzC2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Gompertz C"
    _HTML = "y = a * exp(b * exp(c * x))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * exp(coeff[1] * exp(coeff[2] * _id[_cwo[0]+i]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * exp(b * exp(c*x_in));\n"
        return s



class LogisticA2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Logistic A"
    _HTML = "y = a / (1.0 + b*exp(-cx))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] / (1.0 + coeff[1] * exp(coeff[2] * _id[_cwo[1]+i]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_NegX(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a / (1.0 + b*exp(-1.0 * c * x_in));\n"
        return s



class LogisticB2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Logistic B"
    _HTML = "y = a / (1.0 + (x/b)<SUP>c</SUP>)"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] / (1.0 + pow(_id[_cwo[0]+i] / coeff[1], coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_NegX(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a / (1.0 + pow(x_in/b, c));\n"
        return s



class Weibull2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Weibull"
    _HTML = "y = a - b*exp(-cx<sup>d</sup>)"
    coefficientDesignatorTuple = ("a", "b", "c", "d")
    function_cpp_code = 'temp = coeff[0] - coeff[1] * exp(-1.0 * coeff[2] * pow(_id[_cwo[2]+i], coeff[3]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a - b*exp(-1.0 * c * pow(x_in, d));\n"
        return s



class WeibullPDF2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Weibull PDF"
    _HTML = "y = (a/b) * (x/b)<SUP>(a-1.0)</SUP> * exp(-(x/b)<sup>a</sup>)"
    coefficientDesignatorTuple = ("a", "b")
    function_cpp_code = 'temp = (coeff[0] / coeff[1]) * pow(_id[_cwo[0]+i] / coeff[1], coeff[0] - 1.0) * exp(-1.0 * pow(_id[_cwo[0]+i] / coeff[1], coeff[0]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = (a/b) * pow(x_in/b, a-1.0) * exp(-1.0 * pow(x_in/b, a));\n"
        return s



class WeibullCDF2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Weibull CDF"
    _HTML = "y = 1.0 - exp(-(x/b)<sup>a</sup>)"
    coefficientDesignatorTuple = ("a", "b")
    function_cpp_code = 'temp = 1.0 - exp(-1.0 * pow(_id[_cwo[0]+i] / coeff[1], coeff[0]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = 1.0 - exp(-1.0 * pow(x_in/b, a));\n"
        return s



class MagneticSaturation2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Magnetic Saturation"
    _HTML = "y = ax * (1.0 + b*exp(cx))"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * _id[_cwo[0]+i] *(1.0 + coeff[1] * exp(coeff[2] * _id[_cwo[0]+i]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a*x_in * (1.0 + b*exp(c*x_in));\n"
        return s



class Chapman2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Chapman"
    _HTML = "y = a * (1.0 - exp(-bx))<sup>c</sup>"
    coefficientDesignatorTuple = ("a", "b", 'c')
    function_cpp_code = 'temp = coeff[0] * pow(1.0 - exp(-1.0 * coeff[1] * _id[_cwo[0]+i]), coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(1.0 - exp(-1.0 * b * x_in), c);\n"
        return s



class Hill2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name = "Hill"
    _HTML = "y = ax<sup>b</sup> / (c<sup>b</sup> + x<sup>b</sup>)"
    coefficientDesignatorTuple = ("a", "b", 'c')
    function_cpp_code = 'temp = coeff[0] * pow(_id[_cwo[0]+i], coeff[1]) / (pow(coeff[2], coeff[1]) + pow(_id[_cwo[0]+i], coeff[1]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(x_in, b) / (pow(c, b) + pow(x_in, b));\n"
        return s
